import { defineConfig } from "vite"; // 帮手函数，这样不用 jsdoc 注解也可以获取类型提示
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import vue from "@vitejs/plugin-vue";
const { resolve } = require("path");

// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
  return {
    plugins: [
      vue(),
      createSvgIconsPlugin({
        iconDirs: [resolve(process.cwd(), "src/assets/svg")],
        symbolId: "icon-[dir]-[name]",
        svgoOptions: command === "build",
      }),
    ],
    resolve: {
      alias: { "@": resolve(__dirname, "src") },
      extensions: [".vue", ".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".css", ".scss", ".sass"],
    },
    server: {
      host: "0.0.0.0",
      port: 3000, // 设置服务启动端口号
      cors: true, // 允许跨域
    },
  };
});
